let authBase = "http://localhost:9000";
let basicBase = "http://localhost:9000";
let preRequest = {};
let auth = {
  login: function (account) {
    return window.axios({
      method: "post",
      url: authBase + "/login",
      data: `username=${account.username}&password=${account.password}`,
    });
  },
  logout: function () {},
};

let basic = {};
basic.query4submitter = function (queryCondition) {
  return window.axios({
    method: "post",
    url: basicBase + "/basic/shopping/query4submitter",
    data: queryCondition,
  });
};
basic.query4auditor = function (queryCondition) {
  return window.axios({
    method: "post",
    url: basicBase + "/basic/shopping/query4auditor",
    data: queryCondition,
  });
};
basic.insert = function (shoppingBill) {
  return window.axios({
    method: "post",
    url: basicBase + "/basic/shopping/insert",
    data: shoppingBill,
  });
};
basic.findById = function (id) {
  return window.axios({
    method: "get",
    url: `${basicBase}/basic/shopping/find/${id}`,
  });
};
basic.modify = function (shoppingBill) {
  return window.axios({
    method: "put",
    url: basicBase + "/basic/shopping/modify",
    data: shoppingBill,
  });
};
basic.submit = function (id) {
  return window.axios({
    method: "put",
    url: `${basicBase}/basic/shopping/submit/${id}`,
  });
};
basic.resubmit = function (id) {
  return window.axios({
    method: "put",
    url: `${basicBase}/basic/shopping/resubmit/${id}`,
  });
};
basic.audit = function (data) {
  return window.axios({
    method: "put",
    url: basicBase + "/basic/shopping/audit",
    data: data,
  });
};

basic.materialQuery = function (queryCondition) {
  return window.axios({
    method: "post",
    url: basicBase + "/basic/material/query",
    data: queryCondition,
  });
};

preRequest.shoppingStates = function () {
  return window.axios({
    method: "get",
    url: basicBase + "/basic/shopping/shoppingStates",
  });
};

export { auth, basic, preRequest };
